[Server] Keep one unregistrable element from taking the whole registry down - #477
Open
wachterjohannes wants to merge 1 commit into
Conversation
wachterjohannes
requested review from
CodeWithKyrian,
Nyholm,
chr-hertel and
soyuka
as code owners
August 23, 2026 20:30
chr-hertel
reviewed
Aug 23, 2026
wachterjohannes
force-pushed
the
fix/resource-template-validation-at-registration
branch
from
August 24, 2026 21:37
69190d8 to
737ec3b
Compare
wachterjohannes
force-pushed
the
fix/resource-template-validation-at-registration
branch
from
August 24, 2026 21:40
737ec3b to
76fb3ec
Compare
…y down A placeholder-less resource template made the server serve nothing. `ReflectedElementLoader` wrapped the failure in a `ConfigurationException` and rethrew it, which aborted `Registry::load()` before any element was registered. Loading is lazy by default, so that ran while a request was being served: `tools/list` and `tools/call` answered `-32602` with the template's message, and since `load()` marks itself loaded only on success, every following request repeated it. The loader now logs the failure and skips that element, the way `Discoverer` already treats an attribute it cannot process. The bad template is the only thing missing; the rest of the registry stays servable, and a server-side configuration error stops being reported to the client as invalid params on unrelated calls. Applies to all four element types, which carried the same rethrow. The `ResourceTemplate` message now also says what to do about it: a URI without a placeholder addresses a single resource, so it belongs in `addResource()`. Fixes modelcontextprotocol#476.
wachterjohannes
force-pushed
the
fix/resource-template-validation-at-registration
branch
from
August 24, 2026 21:41
76fb3ec to
12856e0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #476.
A placeholder-less resource template made the server serve nothing.
ReflectedElementLoaderwrapped the failure in aConfigurationExceptionand rethrew it, which abortedRegistry::load()before any element was registered. Loading is lazy by default, so that ran while a request was being served:tools/listandtools/callanswered-32602with the template's message, and sinceload()marks itself loaded only on success, every following request repeated it.The loader now logs the failure and skips that element, the way
Discovereralready treats an attribute it cannot process (Discoverer.php:300-310). The bad template is the only thing missing; the rest of the registry stays servable, and a server-side configuration error stops being reported to the client as invalid params on unrelated calls. All four element types carried the same rethrow, so all four change.The
ResourceTemplatemessage now also says what to do about it: a URI without a placeholder addresses a single resource, so it belongs inaddResource().Changed from the first revision
The first take validated the URI template in
Builder::addResourceTemplate(). @chr-hertel pushed back on that, rightly: every schema invariant would end up mirrored in the builder alongside the value object that already owns it, and theResourceTemplate::isValidUriTemplate()accessor existed only to make that mirroring possible. Both are gone. Nothing inBuilderchanged, and this revision fixes the reported path — the#[McpResourceTemplate]blast radius — rather than one doorway into it.